#ifndef _FIG_BONE_FILE_CACHE_H_
#define _FIG_BONE_FILE_CACHE_H_

#include "fig_bone_animation.h"

#include "num/named_set.h"

#include "math/vec2.h"
#include <vector>

struct BoneFileData;

class FIGBoneFileCache 
{
public:

	static FIGBoneFileCache&			Instance();

	struct BoneData
	{
		int				ID;
		std::string		Name;	

		BoneData() : ID(0)
		{

		}
	};

			
	struct AnimationPartData
	{
	    int				ID;
        float			Rotation;
		math::Vec2		CenterRelative;

		AnimationPartData() :
					ID(0),
					Rotation(0)
		{

		}
	};

	struct AnimationData
	{
		int				StepID;
		float			Duration;

		std::vector<FIGBoneFileCache::AnimationPartData*>	m_AnimationPartDatas;

		AnimationData() :
				StepID(0),
				Duration(0)
		{

		}
	};

	struct BoneFileData
	{
		std::vector<FIGBoneFileCache::BoneData*>		m_BoneDatas;		
		std::vector<FIGBoneFileCache::AnimationData*>	m_AnimationDatas;
		std::vector<FIGBoneAnimation::WayPoint*>		m_pWPs;	
	};

	typedef	void (*FileLoadedCB)(void* pData);

	void												ReadAndCacheFiles(FileLoadedCB pCB, void* pData);
	void												ReadSingleFile(const std::string& FileName);
	BoneFileData*										GetBoneFileDataByFileName(const std::string& Name);

protected:

	FIGBoneFileCache();


	

	
	num::NamedSet<FIGBoneFileCache::BoneFileData*>		m_BoneFileDatas;
};


#endif